package com.ship.dispatch.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ship.common.core.web.domain.JsonResult;
import com.ship.dispatch.bean.SpRoute;
import com.ship.dispatch.service.SpPortInformationService;
import com.ship.dispatch.service.SpPortRouteDistanceService;
import com.ship.dispatch.service.SpRouteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedList;
import java.util.List;

/**
 * 船舶调度海峡-海区管理
 *
 * @author zhangyh
 * @since 2024-01-10
 */
@RestController
@RequestMapping("/ship/dispatch/route")
@Api(value = "shipDispatchRoute", tags = "船舶调度海峡-海区管理")
public class SpRouteController {

    @Autowired
    private SpRouteService spRouteService;

    @Autowired
    private SpPortInformationService spPortInformationService;

    @Autowired
    private SpPortRouteDistanceService spPortRouteDistanceService;

    /**
     * 获取海峡/海区列表
     *
     * @return
     */
    @ApiOperation(value = "获取海峡/海区列表")
    @PostMapping(value = "/list")
    public JsonResult<List<SpRoute>> getList(@RequestBody SpRoute dto) {
        QueryWrapper wrapper = new QueryWrapper();
        return JsonResult.success(spRouteService.pageExportList(dto,wrapper,new LinkedList<>()));
    }

    /**
     * 更新港口航线规划结果数据
     *
     * @return
     */
    @ApiOperation(value = "更新港口航线规划结果数据")
    @GetMapping(value = "/portRouteRelationUpdate")
    public JsonResult portRouteRelationUpdate() {
        spPortRouteDistanceService.portRouteRelationUpdate();
        return JsonResult.success();
    }




}
